package com.mall.util;


import java.text.SimpleDateFormat;
import java.util.Date;


public class DateUtil {
	public static final String DATE_FORMAT_LONG = "yyyy-MM-dd HH:mm:ss";
	public static final String DATE_FORMAT_LONG_MIN = "yyyyMMddHHmmss";
	public static final String DATE_FORMAT_MID = "yyyy-MM-dd HH:mm";
	public static final String DATE_FORMAT_SHORT = "yyyy-MM-dd";
	public static final String DATE_FORMAT_MONTH = "MM-dd";
	public static final String DATE_FORMAT_SHORT_MIN = "yyyyMMdd";

	public static final String TIME_FORMAT_LONG = "HH:mm";

	public static final String TIME_FORMAT_SHORT = "HHmm";

	

	
	public static String formatDateToStr(Date date, String format) {
		if (date == null) {
			return "";
		} else {
			SimpleDateFormat dateFormat = new SimpleDateFormat(format);
			String dataStr = dateFormat.format(date);
			return dataStr;
		}
	}
	public static Date formatStrToDate(String str, String format) {
		if (str==null||"".equals(str)) {
			return null;
		} else {
			SimpleDateFormat fmt = new SimpleDateFormat(format);

			try {
				return fmt.parse(str);
			} catch (java.text.ParseException e) {
				return null;
			}

		}
	}

	

	
	
	
}
